import {api} from '__service/api'
import { STATUS_HTTP_SUCCESS, apiHttp} from '__service/csHttp'
//mutations key
export const MESSAGES = 'MESSAGES';
import store from '../store';
export default {
    state: {
        holdFoFCount: 0,             // 投资中母基金
        guestCount: 0,               // 基金储备
        ansatFundCount: 0,           // 拟设立基金
        estFundCount: 0,             // 已设立基金
        latentItemCount: 0,          // 项目储备
        quasiItemCount: 0,           // 拟投资项目
        holdItemCount: 0,            // 持有中项目
        scheduleCount: 0             // 个人中心
    },
    mutations: {
        /**
         * 获取未读消息
         * @param {Object} state
         * @param {Number} obj
         */
        [MESSAGES](state, obj) {
            state = Object.assign(state, obj);
        },
    },
    actions: {
        async getMsg({commit}) {
            if (Object.keys(store.state.user).length > 0) {
                const { data, resCode} = await apiHttp(api.GET_MENU_REMINDS);
                if (resCode === STATUS_HTTP_SUCCESS) {
                    commit(MESSAGES, data);
                }
            }
        }
    }
}
